package com.zmc.order.infrastructure.updater.order;

import com.zmc.order.infrastructure.enums.OrderEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author：zmc
 * @Date：2025/5/15 18:28
 */

@Component
public class OrderFactory<T> {

    @Autowired
    private OrderCreateUpdater<T> orderCreateUpdater;

    @Autowired
    private OrderSplitUpdater<T> orderSplitUpdater;

    @Autowired
    private OrderCancelUpdater<T> orderCancelUpdater;

    @Autowired
    private OrderRefundApplyUpdater<T> orderRefundApplyUpdater;

    @Autowired
    private OrderRefundApproveUpdater<T> orderRefundApproveUpdater;

    @Autowired
    private OrderRefundHandlerUpdater<T> orderRefundHandlerUpdater;

    @Autowired
    private OrderCreateLogisticsUpdater<T> orderCreateLogisticsUpdater;

    @Autowired
    private OrderConfirmShipmentUpdater<T> orderConfirmShipmentUpdater;

    @Autowired
    private OrderConfirmReceiveUpdater<T> orderConfirmReceiveUpdater;

    @Autowired
    private OrderDefaultUpdater<T> orderDefaultUpdater;

    public OderUpdater<T> getOrderUpdater(int status) {
        if (status == OrderEnum.ORDER_UPDATER_CREATE.getCode()) {
            return orderCreateUpdater;
        } else if (status == OrderEnum.ORDER_UPDATER_CANCEL.getCode()) {
            return orderCancelUpdater;
        } else if (status == OrderEnum.ORDER_UPDATER_SPLIT.getCode()) {
            return orderSplitUpdater;
        }else if (status == OrderEnum.ORDER_UPDATER_APPLY_REFUND.getCode()) {
            return orderRefundApplyUpdater;
        }else if (status == OrderEnum.ORDER_UPDATER_APPROVE_REFUND.getCode()) {
            return orderRefundApproveUpdater;
        }else if (status == OrderEnum.ORDER_UPDATER_REFUND_HANDLER.getCode()) {
            return orderRefundHandlerUpdater;
        } else if (status == OrderEnum.ORDER_UPDATER_CREATE_LOGISTICS.getCode()) {
            return orderCreateLogisticsUpdater;
        }else if (status == OrderEnum.ORDER_UPDATER_CONFIRM_SHIPMENT.getCode()) {
            return orderConfirmShipmentUpdater;
        }else if (status == OrderEnum.ORDER_UPDATER_CONFIRM_RECEIVE.getCode()) {
            return orderConfirmReceiveUpdater;
        } else {
            return orderDefaultUpdater;
        }
    }


}
